package com.powerhua.xsys.sys.web;

import com.powerhua.core.web.IServletAction;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * 用户登陆管理
 * @author Brian.Xie
 */
public class SignAction implements IServletAction {

    @Override
    public String doAction(HttpServletRequest request) {
        StringBuffer result = new StringBuffer("");
        String action = request.getParameter("act");
        
        HttpSession session = request.getSession(true);
        if ("signIn".equals(action)) {
            // 从session中获取用户信息
            String userName = request.getParameter("UserName");
            String userPass = request.getParameter("UserPass");
            
            session.setAttribute("user_name", userName);
            request.setAttribute("redirect", true);
            
            result.append("workflow/index.html");
        } else if("info".equals(action)) {
            String r = getUserInfo(session);
            result.append(r);
        }

        // 返回
        return result.toString();
    }
    
    private String signIn(String userName, String userPass) {
        return "";
    }
    
    private String getUserInfo(HttpSession session) {
        return (String)session.getAttribute("user_name");
    }
}
